package com.paziy.notes.core.sounds;

import com.paziy.notes.core.notes.DrumNote;

/**
 * Immutable class wrapper for {DrumNote}
 * @see com.paziy.notes.core.notes.DrumNote
 *
 * @author thecederick@gmail.com (Paziy Evgeniy)
 * @version 0.2
 * @since 0.1 (09.12.13 20:41)
 */
public final class DrumSound implements Sound {

    /**
     * The drum note
     * @see com.paziy.notes.core.notes.DrumNote
     */
    private DrumNote drumNote;

    public DrumSound(DrumNote drumNote) {
        checkDrumNote(drumNote);
        this.drumNote = drumNote;
    }

    /**
     * The getter for drum note.
     *
     * @return drum note
     */
    public DrumNote getDrumNote() {
        return drumNote;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj.getClass() != DrumSound.class) return false;

        DrumSound testing = (DrumSound) obj;

        return getDrumNote() == testing.getDrumNote();
    }

    private void checkDrumNote(DrumNote drumNote) {
        if(drumNote == null)
            throw new RuntimeException(new NullPointerException("DrumSound: DrumNote can't be null"));
    }

    @Override
    public String toString() {
        return drumNote.name();
    }
}
